package com.yhsimon.memento.theory;

/**
 * @author： YHSimon
 * @date： 2021-10-20 13:34
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        originator.setState("状态#1 攻击力1000");
        Caretaker caretaker = new Caretaker();
        //保存了当前的状态
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态#2 攻击力800");

        caretaker.add(originator.saveStateMemento());

        originator.setState("状态#3 攻击力1");
        caretaker.add(originator.saveStateMemento());

        System.out.println("当前状态：" + originator.getState());

        //希望恢复到状态1
        originator.getStateFromMemento(caretaker.get(0));
        System.out.println("恢复后的状态是" + originator.getState());
    }
}
